/*************************************************************************
	> File Name: main.cc
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/09/29 22:49
 ************************************************************************/

#include "comm.hpp"
#include "log.hpp"
#include "threadPool.hpp"
#include "task.hpp"


int main(int argc, char *argv[])
{
    srand((unsigned long)time(nullptr) ^ getpid());
    ThreadPool<Task>::getThreadPool()->run();
    while (1) {
        int x = rand() % 100 + 1;
        usleep(3131);
        int y = rand() % 30 + 1;
        Task t(x, y, [](int x, int y)->int{
            return x + y;
        });
        logMessage(DEBUG, "make task successfully: %d+%d=?", x, y);
        logMessage(DEBUG, "make task successfully: %d+%d=?", x, y);
        logMessage(DEBUG, "make task successfully: %d+%d=?", x, y);
        logMessage(DEBUG, "make task successfully: %d+%d=?", x, y);
        ThreadPool<Task>::getThreadPool()->pushTask(t);
        sleep(1);
    }
    return 0;
}
